const { ccclass, property } = cc._decorator;
declare let eManager,i18n,DBManager,dbh,JsonHttp;
import BaseView from "../../component/BaseView";
import Utils = require("../../utils/Utils");
import PopUIHelper = require("../../utils/PopUIHelper");
import UIHelper = require("../../component/UIHelper");
@ccclass
export default class DeputyGameView extends BaseView {
    @property(sp.Skeleton)
    doneSpine: sp.Skeleton = null;
    @property(sp.Skeleton)
    zhuanChang: sp.Skeleton = null;
    @property(cc.Node)
    nextStep: cc.Node = null;

    @property(cc.Label)
    lblStep: cc.Label = null;
    @property(cc.Label)
    lblDes: cc.Label = null;


    _step = 1;//第几关
    onLoad() {
        super.onLoad();
        eManager.on("DEPUTY_GAME_STEP_DONE", this.onStepDone, this)
        Utils.audioManager.playBGM("huazhuang/deputyGame/deputyGameBg");

        this.updateStepShow();
    };

    onClose(){
        Utils.audioManager.playDefaultBGM();
    };
    start(){
        super.start();
    };

    onStepDone(){
        this.nextStep.active = true;
        this.doneSpine.node.active = true;
        Utils.audioManager.playSound("huazhuang/deputyGame/pass");
    };

    updateStepShow(){
        this.lblStep.string = i18n.t("DEPUTY_GAME_STEP_NAME" + this._step);
        this.lblDes.string = i18n.t("DEPUTY_GAME_STEP_DES" + this._step);
    };
    //下一关
    onClickNext(){
        if(this._step >= 4){
            this.finishGame();
            return;
        }
        this.zhuanChang.node.active = true;
        this.nextStep.active = false;
        this.zhuanChang.setCompleteListener(()=>{
            this.zhuanChang.node.active = false;
        });
        this.zhuanChang.setAnimation(0,"animation",false);
        Utils.audioManager.playSound("huazhuang/deputyGame/zhuanchang");
        //@ts-ignore
        this.scheduleOnce(()=>{
            this.doneSpine.node.active = false;
            this._step ++;
            this.updateStepShow();
        },1);
    };
    //提示
    onClickTips(){
        PopUIHelper.helper.showNewConfirmMsg(i18n.t("DEPUTY_GAME_TIPS" + this._step));
    };

    finishGame(){

    };





    
}
